Ext.draw.engine.ImageExporter.defaultUrl = 'system/saveChart.do';

Ext.form.field.ComboBox.override({
	editable: false
});

Ext.window.Window.override({
	modal: true
});

//Ext.panel.Panel.override({
//	bodyCls: 'x-panel-default-framed-mc'
//});

Ext.tree.Panel.override({
	refreshable: false,
	animate: Ext.isWebKit ? true : false,
	initComponent: function () {
		var me = this;
		this.on('itemappend',function(current,node){
			if(me.refreshable){
				var tree = this;
	    		if(tree.expands && tree.expands[node.data.id]){
	    			node.expand();
	    			delete tree.expands[node.data.id];
	    		}
			}
    	});
        this.callParent();
    },
    getExpandedMap: function(pnode,openednodes){
    	var me = this;
    	openednodes = openednodes || {};
    	pnode = pnode || me.getRootNode();
    	if(pnode.isExpanded()){
    		openednodes[pnode.data.id] = true;
    		pnode.eachChild(function(cnode){
    			me.getExpandedMap(cnode,openednodes);
    		});
    	}
    	
    	return openednodes;
    },
    refresh: function(){
    	this.expands = this.getExpandedMap(this.getRootNode());
    	this.store.load();
    }
});



var desk;
Ext.Loader.setConfig({
	enabled : true,
	paths : {
		'Ext.desk.Frame' : 'javascript/frame',
		'Ext.desk.Control' : 'javascript/frame/control',
		'Module.System' : 'javascript/module/system',
		'Module.Privilege' : 'javascript/module/privilege',
		'Module.jc' : 'javascript/module/jc',
		'Sh.ux' : 'javascript/wiget',
		'Module.task' : 'javascript/module/task',
		'Module.wg' : 'javascript/module/wg',
		'Module.sjfx' : 'javascript/module/sjfx',
		'Module.video' : 'javascript/module/video',
		'Module.test' : 'javascript/module/test',
		'Module.zc' : 'javascript/module/zc',
		'Module.ldjscharts' : 'javascript/module/ldjscharts'
		
	}
});

Ext.onReady(function() {
	var body = Ext.getBody();
	desk = Ext.create('Ext.desk.Frame.Desktop', {
		width : body.getViewSize().width,
		height : body.getViewSize().height,
		border : false,
		renderTo : body
	});
	
	window.onresize = function (){
		desk.setSize($('body').width(),$('body').height());
	};
	//Ajax Response 的错误请求头处理
	Ext.Ajax.on('requestexception', function(conn, response, options, eOpts) {
		var status1 = "409";
		var status2 = "500";
		var error = response.status + ' - ' + response.statusText;
		if(response.status == status1){
			Ext.Msg.alert("警告","由于您长时间未操作，需重新登录！");
			setTimeout(function(){
				window.location.href= basePath+"/login.jsp";
			},2000);
			//window.location.href= basePath+"/login.jsp"
		}
		if(response.status == status2){
			Ext.Msg.alert("警告","超出你的访问权限！");
		}
		
	});
});
